<?php            
class wptottkOptions {               
    function getOptions() {            
        $options = get_option('wptottk_options');               
       if (!is_array($options)) {             
                $options['accesskey'] = '';    
				  $options['secretkey'] = '';    
				    $options['xiangceid'] = '';      
			 $options['fanhuileixin'] = '1';     
			  $options['quwailian'] = '1';     
            update_option('wptottk_options', $options);            
        }      
       return $options;         
    }      
   function init() {      
        if(isset($_POST['classic_save'])) {      
            $options = wptottkOptions::getOptions();     
			 $options['xiaoming'] = stripslashes($_POST['xiaoming']);  
            $options['fanhuileixin'] = stripslashes($_POST['fanhuileixin']);    
			 $options['quwailian'] = stripslashes($_POST['quwailian']);     
			  $options['accesskey'] = stripslashes($_POST['accesskey']);     
			   $options['secretkey'] = stripslashes($_POST['secretkey']);     
			    $options['xiangceid'] = stripslashes($_POST['xiangceid']);     
            update_option('wptottk_options', $options);      
        } else {      
            wptottkOptions::getOptions();            
        }      
        add_plugins_page("贴图库云存储", "贴图库云存储", 'edit_themes', basename(__FILE__), array('wptottkOptions', 'display'));            
    }      
    function display() {           
        $options = wptottkOptions::getOptions(); ?>

<h1>贴图库插件  设置</h1>
<form method="post" enctype="multipart/form-data" name="classic_form" id="classic_form">
				<table class="form-table" >
						<tr>
								<th><strong>AccessKey:</strong></th>
								<td><input class="input3"  type="text" id="accesskey" name="accesskey" size="40" value="<?php echo($options['accesskey']); ?>" /><div>获取AccessKey&SecretKey请前往<a href="http://open.tietuku.com" target="_blank">贴图库开放平台</a></div>
								</td>
						</tr>
						<tr>
								<th><strong>SecretKey:</strong></th>
								<td><input class="input3"  type="text" id="secretkey" name="secretkey" size="40" value="<?php echo($options['secretkey']); ?>" />
								</td>
						</tr>
						<tr>
								<th><strong>相册id:</strong></th>
								<td><input class="input3"  type="text" id="xiangceid" name="xiangceid" size="40" value="<?php echo($options['xiangceid']); ?>" />
								</td>
						</tr>
						<tr>
								<th><strong>图片返回类型:</strong></th>
								<td><select name="fanhuileixin">
												<option value='1'<?php if($options['fanhuileixin'] == '1'){echo 'selected="selected"';}?>>展示图</option>
												<option value='2'<?php if($options['fanhuileixin'] == '2'){echo 'selected="selected"';}?>>缩略图</option>
												<option value='3'<?php if($options['fanhuileixin'] == '3'){echo 'selected="selected"';}?>>原图</option>
												<!--1为展示图 2为缩略图 3为原图 如果填错或不填返回展示图 -->
										</select>
								</td>
						</tr>
						<tr>
								<th><strong>是否去除外链:</strong></th>
								<td><select name="quwailian">
												<option value='1'<?php if($options['quwailian'] == '1'){echo 'selected="selected"';}?>>不去掉外链</option>
												<option value='2'<?php if($options['quwailian'] == '2'){echo 'selected="selected"';}?>>去掉外链</option>
												<!--1为不去掉外链 2为去掉外链 如果填错或不填不去掉外链 -->
										</select>
								</td>
						</tr>
				</table>
				<p class="submit">
						<input class="button-primary" name="classic_save" type="submit" value="保存设置" />
						<input class="button-secondary" name="reset" type="submit" value="重置设置" />
				</p>
				
</form>
<?php            
    }          
}            
add_action('admin_menu', array('wptottkOptions', 'init'));             
?>
